import { create, update, remove, query } from '../../../../framework/service/index';
import { ToastTips } from '../../../../common/toastTips/tosat';

export default {

  namespace: 'citySelect',

  state: {
    customers: {},
    partTimeList:[],
  },

  subscriptions: {
    setup({ dispatch, history }) {
      history.listen(location => {
        if(location.pathname === '/city-select') {
          // dispatch({
          //   type: 'query',
          //   payload: {
          //   }
          // });
        }
      })
    },
  },

  effects: {
    *query({ payload }, { call, put }) {  // eslint-disable-line
      // console.log('id搜商家',payload.id);
      const { code, data, message } = yield call(query, `/api/pub/customers/${payload.id}`, {});
      // console.log('商家详情', JSON.stringify(data));
      if (code === 200 && data) {
        yield put({
          type: 'querySuccess',
          payload: {
            customers: data
          }
        })
      }else{
        console.log('获取商家详情失败');
      }
    },

  },

  reducers: {
    querySuccess(state, action) {
      return { ...state, ...action.payload };
    },
  }

};
